/*绘制直线*/
class Line {
    x: number;
    y: number;
    x1: any;
    y1: any;
    x2: any;
    y2: any;
    rotation: number;
    scaleX: number;
    scaleY: number;
    lineWidth: number;

    constructor(x1 = 0, y1 = 0, x2 = 0, y2 = 0) {
        this.x = 0;
        this.y = 0;
        this.x1 =  x1;
        this.y1 =  y1;
        this.x2 = x2;
        this.y2 = y2;
        this.rotation = 0;
        this.scaleX = 1;
        this.scaleY = 1;
        this.lineWidth = 1;
    }
    draw(context) {
        context.save();
        context.translate(this.x, this.y); //平移
        context.rotate(this.rotation); // 旋转
        context.scale(this.scaleX, this.scaleY);
        context.lineWidth = this.lineWidth;
        context.beginPath();
        context.moveTo(this.x1, this.y1);
        context.lineTo(this.x2, this.y2);
        context.closePath();
        context.stroke();
        context.restore();
    };
};